package component.show.containers
{
	import common.core.GSprite;
	import common.manager.Resource;
	
	import component.show.control.UISprite;
	
	import flash.display.BitmapData;
	import flash.geom.Rectangle;

	public class UIFrame extends UISprite
	{
		private var m_skinName : String = "";
		
		public function UIFrame()
		{
			this.width = 20;
			this.height = 20;
		}
		
		public override function drawBckgound():void
		{
			this.graphics.clear();
			this.graphics.beginFill(0xff0000,0);
			this.graphics.drawRect(0,0,this.width,this.height);
			this.graphics.endFill();
		}
		
		/**
		 * 设置皮肤名后会自动在UISkin.swf中找到皮肤的
		 * @param name 
		 */		
		public function set skinName(name : String) : void
		{
			m_skinName = name;	
			
			if(!name) return;
			
			var clas:Class = Resource.getClass(m_skinName,"UISkin");
			var bit : BitmapData = new clas; 
				
			setBitmapBackground(bit);
		}
			
		public function get skinName() : String
		{
			return m_skinName;
		}
			
		public override function setBitmapBackground(bitmapData:BitmapData, scale9Grid:Rectangle = null):void
		{
			super.setBitmapBackground(bitmapData,scale9Grid);
				
			this.width = bitmapData.width;
			this.height = bitmapData.height;
		}
	}
}